package com.wn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wn.bean.House;
import com.wn.bean.Owner;
import com.wn.mapper.HouseMapper;
import com.wn.service.IHouseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.service.IOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yellow Docter
 * @since 2022-05-20
 */
@Service
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements IHouseService {

    @Autowired
    private IOwnerService iOwnerService;

    @Override
    public House findHouseById(Integer id) {

        House hosue = this.getById(id);

        //house里面有 owner 查询owner
        QueryWrapper<Owner> qr = new QueryWrapper<>();
        qr.eq("house_id",hosue.getId());
        Owner one = iOwnerService.getOne(qr);
        hosue.setOwner(one);

        return hosue;
    }
}
